var e = require("../../../../@babel/runtime/helpers/toConsumableArray");
Component({
  options: {
    virtualHost: !0
  },
  properties: {
    list: {
      type: Array,
      value: []
    },
    level: {
      type: Number,
      value: 0
    },
    parentIndex: {
      type: Number,
      value: 0
    },
    currentActive: {
      type: Number,
      value: 0
    },
    active: {
      type: Object,
      value: {}
    }
  },
  data: {
    scrollId: null,
    activeAry: [],
    oldParent: null
  },
  observers: {
    "active, parentIndex": function (e, t) {
      this.setData({
        activeAry: e[t] || []
      })
    },
    parentIndex: function (t) {
      var a = this.data,
        r = a.activeAry,
        l = a.level,
        i = a.oldParent;
      if (l > 0 && i != t) {
        var n = r.length ? Math.min.apply(Math, e(r)) : 0;
        this.setData({
          scrollId: "scrollId".concat(n),
          oldParent: t
        })
      }
    }
  },
  externalClasses: ["custom-class"],
  methods: {
    onClickItem: function (e) {
      var t = e.currentTarget.dataset,
        a = t.index,
        r = t.item,
        l = this.data.level;
      this.setData({
        currentActive: a
      }), this.triggerEvent("itemClick", {
        item: r,
        index: a,
        level: l
      })
    }
  },
  lifetimes: {
    ready: function () {
      var t = this.data,
        a = t.level,
        r = t.activeAry,
        l = t.active,
        i = 0;
      if (0 == a) {
        var n = Object.keys(l).map((function (e) {
          return +e
        }));
        i = Math.min.apply(Math, e(n))
      } else if (r.length) {
        var s = this.data.activeAry;
        i = Math.min.apply(Math, e(s))
      }
      this.setData({
        scrollId: "scrollId".concat(i)
      })
    }
  }
});